package com.biscuit.page.basicservice.utils;


import com.biscuit.page.basicservice.model.enums.BaseResponseEnum;
import com.biscuit.page.basicservice.model.exception.BaseException;

/**
 * @author mazihao
 * @createTime 2024/3/7 17:21
 */
public class BaseExceptionUtil {

    public static void throwException(boolean condition, String message) {
        if (!condition) {
            throw new BaseException(message);
        }
    }

    public static void throwException(boolean condition, BaseResponseEnum exEnum) {
        if (!condition) {
            throw new BaseException(exEnum.getCode(), exEnum.getMessage());
        }
    }

    public static void throwException(boolean condition, String message, BaseResponseEnum exEnum) {
        if (!condition) {
            throw new BaseException(exEnum.getCode(), message);
        }
    }

    public static void throwException(BaseResponseEnum exEnum, String message) {
        throw new BaseException(exEnum.getCode(), message);
    }

}
